/**财务**/
applyWithdraw={
	//单个审核
	single:function(auto_verify_val){
		var row=$('#finance-applyWithdraw-dg').datagrid('getSelections');
		if(row.length != 1)
		{
			$.messager.alert('提示','一次只能审核一个.','info');
		}
		else
		{
			$.messager.confirm('提示','您真的要审核吗?',function(r){
				if(r)
				{
					// var ids=[];
					// for(var i=0; i<row.length; i++)
					// {
					// 	ids.push(row[i].id);
					// }
					var ids = row[0].id;
					//如果是自动审核中的不能审核操作
					if (row[0].check_status == auto_verify_val)
					{
						$.messager.alert('错误提示','自动审核中,不能手动操作','error');
						return false;
					}
					
					//审核
					$.post(approvalUrl, {id:ids},function(result){
						if(result.status=='1')
						{
							$('#finance-applyWithdraw-dg').datagrid('reload');
						}
						else
						{
							$.messager.alert('错误提示',result.message,'error');
						}
					});
				}
			});

		}
	},

	multi:function(auto_verify_val){
		//批量审核
		var row=$('#finance-applyWithdraw-dg').datagrid('getSelections');
		var err_msg = '';
		var ids=[];
		for(var i=0; i<row.length; i++)
		{
			//如果是自动审核中的不能审核操作
			if (row[i].check_status == auto_verify_val)
			{
				if (err_msg == '')
				{
					err_msg = 'id:' + row[i].id + ',用户id：' + row[i].uid + ',用户姓名' + row[i].real_name + ',提现申请金额：' + row[i].money + ',自动审核中,不能手动操作';
				}
				else
				{
					err_msg += '<br />' + 'id:' + row[i].id + ',用户id：' + row[i].uid + ',用户姓名' + row[i].real_name + ',提现申请金额：' + row[i].money + ',自动审核中,不能手动操作';	
				}
			}
				
			ids.push(row[i].id);
		}
		
		if (err_msg != '')
		{
			$.messager.alert('错误提示',err_msg,'error');
			return false;
		}
		
		//var ids = row[0].id;
		$.messager.confirm('提示','您真的要审核吗?',function(r){
			if(r)
			{
				//审核
				$.post(approvalMultiUrl, {id:ids},function(result){
					if(result.status=='1')
					{
						$('#finance-applyWithdraw-dg').datagrid('reload');
						$('#finance-applyWithdraw-dg').datagrid('clearSelections'); 
					}
					else
					{
						$.messager.alert('错误提示',result.message,'error');
						$('#finance-applyWithdraw-dg').datagrid('clearSelections'); 
					}
				});
			}
		});
	},
	view:function(){
		//查看流水
		
		var row=$('#finance-applyWithdraw-dg').datagrid('getSelections');
		if (row.length == 0)
		{
			$.messager.alert('提示','请选择!','info');
			return false;
		}
		if(row.length != 1)
		{
			$.messager.alert('提示','一次只能查看一个.','info');
			return false;
		}
		var id = row[0].id;
		showTab(userInfoUrl+'?id='+id,'查看用户流水');
		// $('#finance-user-info').window('refresh',userInfoUrl);
	},
	rejectBar:function(){
		//驳回按钮
		var row=$('#finance-applyWithdraw-dg').datagrid('getSelections');
		if (row.length == 0)
		{
			$.messager.alert('提示','请选择!','info');
			return false;
		}
		if(row.length != 1)
		{
			$.messager.alert('提示','一次只能驳回一个.','info');
		}
		else
		{
			$('#finance-reject-dialog').dialog('open').dialog('setTitle','驳回');
			$('#finance-reject-dialog-form').form('clear');
		}
	},
	reject:function(){
		//驳回操作
		var row=$('#finance-applyWithdraw-dg').datagrid('getSelections');
		var id = row[0].id;

		//驳回理由
		var reason = $.trim($('#reject-reason').val());
		$('#finance-reject-dialog-form').form('submit',{
			url:rejectUrl,
			queryParams:{key:id},
			onSubmit:function(){
				return $(this).form('validate');
			},
			success:function(result){
				var result=eval('('+result+')');
				if(result.status == '1')
				{
					$('#finance-reject-dialog').dialog('close');
					$('#finance-applyWithdraw-dg').datagrid('reload');
					$('#finance-applyWithdraw-dg').datagrid('clearSelections'); 
				}
				else
				{
					$.messager.confirm('错误提示','操作失败',function(r){
                    	$('#finance-reject-dialog').dialog('close');
                    	$('#finance-applyWithdraw-dg').datagrid('clearSelections'); 
                    });
				}
			}
		});

	}
}
